<?php
//var_dump();
class Kmcategory  extends BaseModel
{
	public $res;
	public $redis_key="";
	public function getSource()
		    {
				return "km_category";
    }
	public function initialize()
	{
		parent::initialize();
	}

    /**
     * 获取栏目列表
     */
    public function get_list(){
        $condition = "is_show=1";
        $info = $this::find(
            array(
                $condition,
                'columns'=>'id,name',
                'order'=>'sort desc,id asc'
            )
        );
        return $info;
    }


    /**
     * 获取指定栏目的名称
     */
    public function get_category_name($cate_id){
        if($cate_id == -1){
            $condition = "is_show=1";// and is_jingxuan=1 推荐栏目
        }else{
            $condition = "is_show=1 and FIND_IN_SET('{$cate_id}',id)";
        }
        $info = $this::find(
            array(
                $condition,
                'columns'=>'id,name',
                'order'=>'sort desc,id asc'
            )
        )->toarray();
        return $info;
    }



}
